<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

class CreateUserCountsTable extends Migration
{
    private $table = 'user_counts';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create($this->table, function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('user_id')->default(0)->comment('用户id');
            $table->unsignedInteger('coin')->default(0)->comment('金币余额');
            $table->unsignedInteger('total_game')->default(0)->comment('总游戏数');
            $table->unsignedInteger('total_earned')->default(0)->comment('总赢得奖金');
            $table->unsignedInteger('total_winning')->default(0)->comment('总赢取次数');
            $table->double('longest_drive')->default(0)->comment('最长距离');
            $table->double('ball_putted')->default(0)->comment('进洞次数');
            $table->double('hole_in_one')->default(0)->comment('一杆进洞次数');
            $table->double('albatross')->default(0)->comment('albatross次数');
            $table->double('eagle')->default(0)->comment('eagle次数');
            $table->double('birdy')->default(0)->comment('birdy次数');
            
            $table->timestamps();
        });

        DB::statement("ALTER TABLE `{$this->table}` COMMENT '用户计数表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists($this->table);
    }
}
